//
//  DDPayTableViewCell.m
//  DingDongZP
//
//  Created by 杨政涛 on 16/10/13.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

#import "DDPayTableViewCell.h"

@implementation DDPayTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self){
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.logoImage = [[UIImageView alloc]init];
        self.logoImage.layer.masksToBounds = YES;
        self.logoImage.layer.cornerRadius = 5;
        [self.contentView addSubview:self.logoImage];
        
        self.payStyle = [[UILabel alloc]init];
        self.payStyle.textColor = COLOR_FONT_BLACK;
        self.payStyle.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.payStyle];
        
        self.subtitle = [[UILabel alloc]init];
        self.subtitle.textColor = COLOR_FONT_LIGHT_GRAY;
        self.subtitle.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.subtitle];
        
        
        self.selectedImage = [[UIImageView alloc]init];
        self.selectedImage.layer.masksToBounds = YES;
        self.selectedImage.image = [UIImage imageNamed:@"gou2"];
        [self.contentView addSubview:self.selectedImage];
        
        UIView *divideLine = [[UIView alloc]init];
        divideLine.backgroundColor = [UIColor colorWithWhite:0.863 alpha:1.000];
        [self.contentView addSubview:divideLine];
        
        WEAKSELF
        [divideLine mas_makeConstraints:^(MASConstraintMaker *make){
                
                make.bottom.mas_equalTo(weakSelf.bottom).offset(-0.4);
                make.left.mas_equalTo(weakSelf);
                make.right.mas_equalTo(weakSelf);
                make.height.equalTo(@(0.5));
            }];
            
        [self.logoImage mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.top.mas_equalTo(weakSelf).offset(15);
            make.left.mas_equalTo(weakSelf).offset(20);
            make.bottom.mas_equalTo(weakSelf).offset(-15);
            make.width.equalTo(@(32));
            make.height.equalTo(@(35));
        }];
        
        [self.payStyle mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.top.mas_equalTo(weakSelf).offset(15);
            make.left.mas_equalTo(self.logoImage.mas_right).offset(20);
            make.right.mas_equalTo(weakSelf).offset(-55);

        }];
        
        [self.subtitle mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.top.mas_equalTo(self.payStyle.mas_bottom).offset(3);
            make.left.mas_equalTo(self.payStyle);
            make.right.mas_equalTo(self.payStyle);
            make.height.equalTo(@(15));
        }];
        
        self.selectedImage.layer.cornerRadius = 23/2;
        [self.selectedImage mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.right.mas_equalTo(weakSelf).offset(-20);
            make.centerY.mas_equalTo(weakSelf);
            make.width.height.equalTo(@(23));
        }];
    }
    return self;
}

- (void)setDataModel:(DDPayStyleModel *)dataModel
{
    self.logoImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",dataModel.leftImage]];
    self.payStyle.text = dataModel.payStyle;
    self.subtitle.text = dataModel.subtitle;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
